package com.notes.algo.sx;

public class Solution6 {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		String ip = sc.nextLine();

		String result = isIPV4(ip) ? "IPV4" : isIPV6(ip) ? "IPV6" : "ERROR";
		System.out.println(result);
	}

	public static boolean isIPV4(String ip) {
		if (!ip.contains(".")) {
			return false;
		}

		String[] ipArr = ip.split("\\.", -1);
		int len = ipArr.length;
		// ip段位4个
		if (ipArr.length != 4) {
			return false;
		}

		for (int i = 0; i < len; i ++) {
			String curPart = ipArr[i];
			int curPartLen = curPart.length();
			// ip段长度为1-3
			if (curPartLen <= 0 || curPartLen > 3) {
				return false;
			}
			// 多个数字时不能存在前导0
			if (curPartLen > 1 && curPart.startsWith("0")) {
				return false;
			}

			for (int j = 0; j < curPartLen; j ++) {
				char curPartJ = curPart.charAt(j);
				// 只能是数字
				if (curPartJ < '0' || curPartJ > '9') {
					return false;
				}
			}

			int curPartVal = Integer.valueOf(curPart);
			// 最大值为255
			if (curPartVal > 255) {
				return false;
			}
		}

		return true;
	}

	public static boolean isIPV6(String ip) {
		if (!ip.contains(":")) {
			return false;
		}

		String[] ipArr = ip.split(":", -1);
		int len = ipArr.length;
		// ip段位8个
		if (len == 0 || len > 8) {
			return false;
		}

		for (int i = 0; i < len; i ++) {
			String curPart = ipArr[i];
			int curPartLen = curPart.length();
			// 单个ip段长度为1-4
			if (curPartLen <= 0 || curPartLen > 4) {
				return false;
			}

			for (int j = 0; j < curPartLen; j ++) {
				char curPartJ = curPart.charAt(j);
				// 只能有数字及16进制数组成
				if (!(curPartJ >= '0' && curPartJ <= '9') && !(curPartJ >= 'a' && curPartJ <= 'f') && !(curPartJ >= 'A' && curPartJ <= 'F')) {
					return false;
				}
			}

		}

		return true;
	}
}
